<%--
  Created by IntelliJ IDEA.
  User: Crush
  Date: 2019/11/13
  Time: 17:30
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/page/include/taglib.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
    <meta charset="utf-8">
    <title>用户列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="${ctx }/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="${ctx }/css/font_eolqem241z66flxr.css" media="all" />
    <link rel="stylesheet" href="${ctx }/css/list.css" media="all" />
    <script>
        var ctx = "${ctx}";  //地址前缀
    </script>
</head>

<body class="childrenBody">
<blockquote class="layui-elem-quote news_search">
    <form  class="layui-form-item">



        <span class="layui-anim-fadein">
            <span style="text-align:right;"><font size="5">资产打印</font></span>
            <button class="layui-btn" type="button" style="float:right;">打印</button>
                    <!--模板是将表结构打开到EXCEL-->
        </span>


</blockquote>
</form>
<div class="layui-form">
    <table id="businessDemo" lay-filter="logList"></table>
</div>

<script type="text/javascript" src="${ctx }/layui/layui.js"></script>
<script type="text/html" id="sexTpl">
    {{#  if(d.sex === '0'){ }}
    <span style="color: #F581B1;">女</span>
    {{#  } else if(d.sex === '1'){ }}
    男
    {{#  } else{ }}
    保密
    {{#  } }}
</script>
<script>
    layui.config({
        base : "js/"
    }).use(['form','layer','jquery','table','laydate'],function(){
        var form = layui.form,table = layui.table,
            layer = parent.layer === undefined ? layui.layer : parent.layer,
            laydate = layui.laydate,
            $ = layui.jquery;
        nowTime = new Date().valueOf(),max = null, active = {
            //查询时间
            search: function(){
                var operation=$("#operation"),createTimeStart=$("#createTimeStart"),createTimeEnd=$("#createTimeEnd");
                //执行重载
                table.reload('businessDemo', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    ,where: {
                        //key查询条件关键字: {
                        operation:operation.val(),
                        createTimeStart:createTimeStart.val(),
                        createTimeEnd:createTimeEnd.val()
                        //}
                    }
                });
            }
        };

        // 获取起始时间
        var start = laydate.render({
            elem: '#createTimeStart',
            type: 'datetime',
            max: nowTime,
            btns: ['clear', 'confirm'],
            done: function(value, date){
                endMax = end.config.max;
                end.config.min = date;
                end.config.min.month = date.month -1;
            }
        });
        //获取结束时间
        var end = laydate.render({
            elem: '#createTimeEnd',
            type: 'datetime',
            max: nowTime,
            done: function(value, date){
                if($.trim(value) == ''){
                    var curDate = new Date();
                    date = {'date': curDate.getDate(), 'month': curDate.getMonth()+1, 'year': curDate.getFullYear()};
                }
                start.config.max = date;
                start.config.max.month = date.month -1;
            }
        })

        //加载页面数据
        table.render({
            id:'businessDemo'
            ,elem: '#businessDemo'
            ,url: ctx+'/business/demo/list' //数据接口
            ,limit:10//每页默认数
            ,limits:[10,20,30,40]
            ,cols: [[ //表头
                {field:'id', title: '费用ID',width:170,sort:true}
                ,{field:'bId', title: '业务ID'}
                ,{field:'demoName', title: '用例名称'}
                ,{field:'demoValue', title: '用例值'}
                ,{field:'demoRemark', title: '用例描述'}
                ,{field:'userId', title: '创建用户ID'}
                ,{field:'createTime', title: '创建时间',sort:true}
                ,{field:'operate', title: '数据状态'}
            ]]
            ,page: true //开启分页
            //日期格式化
            ,where: {timestamp: (new Date()).valueOf()}
        });


        //查询
        $(".search_btn").click(function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        })

    })

    //格式化时间
    function formatTime(datetime,fmt){
        alert(datetime)
        if(datetime==null||datetime==0){
            return "";
        }
        if (parseInt(datetime)==datetime) {
            if (datetime.length==10) {
                datetime=parseInt(datetime)*1000;
            } else if(datetime.length==13) {
                datetime=parseInt(datetime);
            }
        }
        datetime=new Date(datetime);
        var o = {
            "M+" : datetime.getMonth()+1,                 //月份
            "d+" : datetime.getDate(),                    //日
            "h+" : datetime.getHours(),                   //小时
            "m+" : datetime.getMinutes(),                 //分
            "s+" : datetime.getSeconds(),                 //秒
            "q+" : Math.floor((datetime.getMonth()+3)/3), //季度
            "S"  : datetime.getMilliseconds()             //毫秒
        };
        if(/(y+)/.test(fmt))
            fmt=fmt.replace(RegExp.$1, (datetime.getFullYear()+"").substr(4 - RegExp.$1.length));
        for(var k in o)
            if(new RegExp("("+ k +")").test(fmt))
                fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));
        return fmt;
    }
</script>
</body>
</html>